package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbItemCatMapper;
import com.dongdongshop.pojo.TbItem;
import com.dongdongshop.pojo.TbItemCat;
import com.dongdongshop.service.ItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description
 * @ClassName ItemCatServiceImpl
 * @Author RC
 * @date 2020.12.11 15:40
 */
@Component
@Service
public class ItemCatServiceImpl implements ItemCatService {
    @Autowired
    private TbItemCatMapper itemCatMapper;
    @Override
    public List<TbItemCat> getListItemCat(Integer startPage, Integer pageSize, Long parentId) {
        return itemCatMapper.getListItemCat(startPage,pageSize,parentId);
    }

    @Override
    public Integer selectCount(Long parentId) {
        return itemCatMapper.selectCount(parentId);
    }

    @Override
    public void saveTtemcat(TbItemCat tbItemCat) {
        int i = itemCatMapper.insertSelective(tbItemCat);
    }

    @Override
    public TbItemCat getItemCatById(Long id) {
        TbItemCat tbItemCat = itemCatMapper.selectByPrimaryKey(id);
        return tbItemCat;
    }

    @Override
    public void updateItem(TbItemCat tbItemCat) {
        int i = itemCatMapper.updateByPrimaryKeySelective(tbItemCat);
    }

    @Override
    public void deleteBatchCat(Integer[] ids) {
      int i = itemCatMapper.deleteBatchCat(ids);
    }

    @Override
    public List<TbItemCat>  getItemCatList(Long id) {
        return itemCatMapper.getInfoById(id);
    }

    @Override
    public long getBrandByTempId(Long id) {
        TbItemCat tbItemCat = itemCatMapper.selectByPrimaryKey(id);

        return tbItemCat.getTypeId();
    }

    @Override
    public TbItemCat findItemByGoodsCagetoryId(Long id) {
        return itemCatMapper.selectByPrimaryKey(id);
    }
}
